# /api/sys/user
# "/api/sys/user/:target 说明：:target就是具体的员工id（如：1281216816277983232）"
import requests

import app


class Employees(object):
    def __init__(self):
        self.add_emp = app.base_url + '/api/sys/user'
        self.manage_emp = app.base_url + '/api/sys/user/'

    def add_employees(self, bearers):
        headers = {"Content-Type": "application/json",
                   "Authorization": f"Bearer {bearers}"
                   }
        data = {
            "username": "hurt0709",
            "mobile": "13872412600",
            "timeOfEntry": "2020-07-28",
            "formOfEmployment": 1,
            "workNumber": "10086",
            "departmentName": "销售",
            "departmentId": "1266699057968001024",
            "correctionTime": "2020-07-30T16:00:00.000Z"
        }
        response = requests.post(url=self.add_emp, headers=headers, json=data)
        return response

    def search_employees(self, target, bearers):
        headers = {"Content-Type": "application/json",
                   "Authorization": f"Bearer {bearers}"
                   }
        return requests.get(url=self.add_emp + '/' + target, headers=headers)

    def alter_employees(self, target, bearers, data):
        headers = {"Content-Type": "application/json",
                   "Authorization": f"Bearer {bearers}"
                   }
        return requests.put(url=self.add_emp + '/' + target, headers=headers, json=data)

    def del_employees(self, target, bearers):
        headers = {"Content-Type": "application/json",
                   "Authorization": f"Bearer {bearers}"
                   }
        return requests.delete(url=self.add_emp + '/' + target, headers=headers)
